echo You have supplied $# arguments to $0: $*

# If we see the -i flag then we need to install the dependent jars to the local maven repository
if [ $1 == '-i' ]
then
	# Install Stragma
	mvn install:install-file \
		-Dfile=lib/stragma-1.0.jar \
		-DgroupId=stragma \
		-DartifactId=stragma \
		-Dversion=1.0 \
		-Dpackaging=jar
		
	# Install StrategoXT
	mvn install:install-file \
		-Dfile=lib/strategoxt-1.0.jar \
		-DgroupId=strategoxt \
		-DartifactId=strategoxt \
		-Dversion=1.0 \
		-Dpackaging=jar
		
	# RE-build stragma-symbian after installing dependent jars
	mvn clean package
fi

# If we see the -p flag then we know a transformation has been requested
# but if we also see the -y flag then we will also execute the yourkit profiling
if [ $1 == '-p' ]
then
	if [ $2 == '-y' ]
	then
		java \
			-agentpath:/Applications/YourKit_Java_Profiler_9.5.6.app/bin/mac/libyjpagent.jnilib=onexit=snapshot,tracing,noj2ee \
			-jar target/stragma-symbian-1.0.jar -p $3 $4 $5
	else	
		java \
			-jar target/stragma-symbian-1.0.jar -p $2 $3 $4
	fi
fi

# If we see the -s flag then the user has requested that we only dump some stats on
# a particular syntax tree
if [ $1 == '-s' ]
then
	java \
	-jar target/stragma-symbian-1.0.jar -s $2
fi
